package cii_lib;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;

public class CII_UDP_Driver {

	/**
	 * @param args
	 */
	public static void main(String[] args) {

		try {
			BufferedReader inFromDevice = new BufferedReader(
					new InputStreamReader(System.in));
			InetAddress IPAdress = InetAddress.getByName("localhost");
//			InetAddress IPAdress = InetAddress.getByName("90.10.11.3");
			DatagramSocket clientSocket = new DatagramSocket(8008,IPAdress);
			byte[] sendData = new byte[1024];
			byte[] getData = new byte[1024];
//			String sentence = inFromDevice.readLine();
			String sentence = "0010111001010A12C3FFFF21230000";
			sendData = sentence.getBytes();
			for (int i=0;i<1000;i++) {
			DatagramPacket sendPacket = new DatagramPacket(sendData, sendData.length, IPAdress, 8008);
			clientSocket.send(sendPacket);
			DatagramPacket getPacket = new DatagramPacket(getData, getData.length);
			clientSocket.receive(getPacket);
			BigInteger data = new BigInteger(getPacket.getData());
			System.out.println("FROM SERV: " + data.toString(16));
			}
			clientSocket.close();
			
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}
